package mtn.bowen.yan.server.service.impl;

import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import mtn.bowen.yan.server.fx.FxmlView;
import mtn.bowen.yan.server.fx.StageManager;
import mtn.bowen.yan.server.service.MainService;
import mtn.bowen.yan.server.service.MenuManagementService;
import mtn.bowen.yan.server.utils.SpringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.File;

/**
 * @author <a href=mailto:yanbowen90@foxmail.com> bowen.yan </a>
 * @version 1.0
 * @description: Main Control
 * @date 2021-10-27 12:08 PM
 */
@Component
public class MainServiceImpl implements MainService {

    private final static Logger LOGGER = LoggerFactory.getLogger(MainServiceImpl.class);

    @Resource
    private MenuManagementService menuManagementService;

    @Override
    public void updateBody(FxmlView view, Label title, ScrollPane body) {

        title.setText(view.title());
        // 构建界面
        SpringUtils.getBean(StageManager.class).switchContent(view, body);

    }

    @Override
    public boolean checkFile(File file) {
        return null == file || 0 == file.length() || !file.exists();
    }
}
